package com.ywk.pattern._24_chain.springchain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * Copyright (C) 2021 思创数码科技股份有限公司
 * <p/>
 * 版权所有
 * <p/>
 * 类名　　  : ResponseResult
 * 功能概要  : 返回结果vo
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class Result implements Serializable {

    private int code;

    private String errorCode;

    private String msg;

    private Object data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /**
     * 成功数据返回
     */
    public static Result success(){
        return Result.builder().code(200).build();
    }
    /**
     * 失败数据返回
     */
    public static Result failure(){
        return Result.builder().code(-1).build();
    }
    public  Boolean isSuccess() {
        return this.code == 200;
    }
}
